/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package justdoit.view;

import justdoit.view.model.PriorityWithIcon;
import java.awt.Component;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;

/**
 * To display the progressBar and priority Icon in the table
 * @author Can
 */
public class TasksTableCellRenderer extends DefaultTableCellRenderer {

    @Override
    protected void setValue(Object value) {
        if (value instanceof PriorityWithIcon) {
            if (value != null) {
                PriorityWithIcon pri = (PriorityWithIcon) value;
                this.setText(pri.getDisplayPriority());
                this.setIcon(pri.getIcon());
                this.setHorizontalAlignment(SwingConstants.LEFT);
            } else {
                this.setText("???");
                this.setIcon(null);
            }
        } else {
            super.setValue(value);
        }
    }

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int row, int column) {
        /*if (value instanceof ProgressBarInTable) {
            if (value != null) {
                return (ProgressBarInTable) value;
            }
        }*/
        return super.getTableCellRendererComponent(
                table, value, isSelected, hasFocus, row, column);
    }
}
